openapi: 3.0.2
info:
  title: FastAPI
  version: 0.1.0
paths:
  /health:
    get:
      tags:
      - tasks
      summary: Healthcheck
      operationId: healthCheck_health_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: { }
  /compose:
    get:
      tags:
      - tasks
      summary: Get Compose Schema
      operationId: getComposeSchema
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                title: Response Get Compose Schema Compose Get
                type: string
  /tasks:
    post:
      tags:
      - tasks
      summary: Create Task
      operationId: createTask
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        400:
          description: invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
    get:
      summary: List tasks
      operationId: listTasks
      responses:
        200:
          description: list all tasks
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchResponse"
    delete:
      summary: Delete all tasks
      operationId: deleteTasks
      responses:
        204:
          description: Successfull delete
        500:
          description: Internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
  /tasks/search:
    post:
      tags:
      - tasks
      summary: Search Modified Task
      operationId: searchTasks
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchRequest"
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchResponse"
        400:
          description: invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
  /tasks/{resource-name}:
    parameters:
    - required: true
      schema:
        $ref: "#/components/schemas/ResourceName"
      name: resource-name
      in: path
    get:
      tags:
      - tasks
      summary: Get Task
      operationId: getTask
      responses:
        200:
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        404:
          description: resource not found
        500:
          description: internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
    put:
      tags:
      - tasks
      summary: Update Task
      operationId: updateTask
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTaskRequest'
        required: true
      responses:
        200:
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        400:
          description: invalid inpit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
    delete:
      tags:
      - tasks
      summary: Delete Task
      operationId: deleteTask
      responses:
        204:
          description: Successful Response
        400:
          description: invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
  /tasks/{resource-name}/suspend:
    parameters:
    - required: true
      schema:
        $ref: "#/components/schemas/ResourceName"
      name: resource-name
      in: path
    post:
      tags:
      - tasks
      summary: Suspend Task
      operationId: suspendTask
      responses:
        201:
          description: suspended successfully
        400:
          description: invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
  /tasks/{resource-name}/resume:
    parameters:
    - required: true
      schema:
        $ref: "#/components/schemas/ResourceName"
      name: resource-name
      in: path
    post:
      tags:
      - tasks
      summary: Resume Task
      operationId: resumeTask
      responses:
        201:
          description: Successful Response
        400:
          description: invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    ResourceName:
      type: string
      example: rn:pvc:v8s:az1:123:456:789
    TaskName:
      type: string
    ProjectId:
      type: string
    Task:
      title: Task
      required:
      - id
      - resource-name
      - task-name
      - status
      - compose
      - clusters
      - created-at
      - modified-at
      - services
      type: object
      properties:
        metadata:
          type: object
          description: kv любых значений
        resource-name:
          $ref: '#/components/schemas/ResourceName'
        task-name:
          $ref: '#/components/schemas/TaskName'        
        status:
          $ref: '#/components/schemas/TaskStatus'
        compose:
          $ref: '#/components/schemas/Compose'
        clusters:
          $ref: '#/components/schemas/Clusters'
        created-at:
          title: Creation Timestamp
          type: string
          format: date-time
        modified-at:
          title: Modified Timestamp
          type: string
          format: date-time
    Compose:
      type: string
    Container:
      title: Container
      required:
      - name
      - status
      type: object
      properties:
        name:
          title: Name
          type: string
        status:
          title: Status
          type: string
    ErrorDto:
      required:
      - code
      - message
      type: object
      properties:
        code:
          type: string
          description: Error code
        message:
          type: string
          description: Error message
        details:
          type: array
          description: Error details as array of arbitrary objects for automated processing
          example:
          - type: error_doc_link
            errorURL: https://sampleurl.tld/docs/error-codes/123
          - type: localized_message
            localizedErrorMessage: Некорректное значение {} параметра {}
            params:
            - xxx
            - limit
          items:
            type: object
            properties: { }
    Clusters:
      additionalProperties:
        $ref: '#/components/schemas/ClusterDetails'
      title: Clusters
      type: object
    ClusterDetails:
      title: ClusterDetails
      required:
      - status
      - resources
      - services
      type: object
      properties:
        resources:
          title: Reosurces
          type: array
          items:
            $ref: '#/components/schemas/Resource'
        status:
          $ref: '#/components/schemas/ClusterStatus'
        services:
          $ref: '#/components/schemas/ServiceDetails'
    ServiceDetails:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/ServiceInfo'
    ServiceInfo:
      title: ServiceInfo
      required:
      - endpoints
      type: object
      properties:
        endpoints:
          title: Endpoints
          type: array
          items:
            type: string
    Resource:
      type: object
      required:
      - kind
      - name
      - status
      properties:
        kind:
          type: string
        name:
          type: string
        status:
          type: string
    TaskStatus:
      enum:
      - creation-request
      - running
      - deletion-request
      - deleted
      - suspension-request
      - suspended
      - resume-request
      - update-request
      - error
      type: string
      description: An enumeration.
    SearchRequest:
      type: object
      properties:
        metadata:
          type: object
          description: kv, по которым происходит фильтрация
        updatedAfter:
          type: string
          format: date-time
        limit:
          type: integer
    SearchResponse:
      type: object
      required:
      - size
      - items
      properties:
        size:
          type: integer
        items:
          type: array
          items:
            $ref: "#/components/schemas/Task"
    CreateTaskRequest:
      required:
      - project
      - compose
      - resource-name
      - task-name
      type: object
      properties:
        metadata:
          type: object
          description: kv любых значений
        resource-name:
          $ref: '#/components/schemas/ResourceName'
        task-name:
          $ref: '#/components/schemas/TaskName'
        project:
          $ref: '#/components/schemas/ProjectId'
        compose:
          $ref: '#/components/schemas/Compose'
    UpdateTaskRequest:
      required:
      - compose
      type: object
      properties:
        metadata:
          type: object
          description: kv любых значений
        compose:
          $ref: '#/components/schemas/Compose'
    ClusterStatus:
      enum:
      - starting
      - running
      - stopped
      - stopping
      - error
      - deleting
      type: string
      description: An enumeration.
